package com.arsn.myf;

import com.arsn.myf.flow.constant.FlowableConstant;
import lombok.extern.slf4j.Slf4j;
import org.flowable.ui.common.conf.DevelopmentConfiguration;
import org.flowable.ui.common.rest.idm.remote.RemoteAccountResource;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration;
import org.springframework.boot.autoconfigure.security.servlet.UserDetailsServiceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.annotation.Import;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.scheduling.annotation.EnableAsync;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 启动类
 * @author arsn
 * @since 2022-05-29
 */
@ComponentScan(
        basePackages = {"com.arsn", FlowableConstant.FLOWABLE_BASE_PACKAGES},
        excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {RemoteAccountResource.class, DevelopmentConfiguration.class})
)
@SpringBootApplication
@EnableAsync
@Slf4j
public class MyfApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(MyfApplication.class);
    }

    public static void main(String[] args) {
        ConfigurableApplicationContext application = SpringApplication.run(MyfApplication.class, args);
        ConfigurableEnvironment environment = application.getEnvironment();
        String port = environment.getProperty("server.port");
        log.info("\n----------------------------------------------------------\n\t" +
                "MyApplication running! Access URLs:\n\t" +
                "Flowable Modeler 流程设计: \thttp://localhost:" + port + "/index.html\n\t" +
                "Swagger文档: \thttp://localhost:" + port + "/doc.html\n" +
                "----------------------------------------------------------");
    }

}
